home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group94a.txt / 000105_icon-group-sender _Wed Apr 27 08:48:03 1994.msg < prev    next >
Internet Message Format  |  1994-08-19  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Wed, 27 Apr 1994 09:01:12 MST
  2. Date: Wed, 27 Apr 94 08:48:03 PDT
  3. From: kwalker@sirtur.premenos.com (Ken Walker)
  4. Message-Id: <9404271548.AA01384@sirtur.premenos.com>
  5. To: icon-group@cs.arizona.edu
  6. Subject: Re: tables, lists, and memory question
  7. X-Sun-Charset: US-ASCII
  8. Content-Length: 1871
  9. Status: R
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11.  
  12. > From: "Art Eschenlauer" <eschen@molbio.cbs.umn.edu>
  13. > I've been wondering for some time now about how (if) Icon knows what
  14. > things to trash.
  15.  
  16. Icon does its own storage management within the memory it malloc()s. When
  17. it does not have room to allocate an object within the memory it has, it
  18. performs a garbage collection to try to recover unused space before it
  19. malloc()s more memory. To perform garbage collection, it starts from a
  20. "basis" of locations that the Icon program can access, for example, the
  21. program's variables, marking things that can be reached. For data types with
  22. pointer semantics, it follows pointers until it reaches an end or reaches
  23. something that has already been marked. When it has marked everything that
  24. the program might use in the future, it can "free" everything else and
  25. compact its allocated memory, relocating pointers to objects it moves.
  26.  
  27. Icon's garbage collection is not perfect, but it is conservative. It may
  28. save a few things it doesn't need to. There is a rather subtle example.
  29. If I remember correctly, it is something like:
  30.  
  31. procedure p()
  32.    local c
  33.  
  34.    c := create write("Hi")
  35.    c := create write("Bye")
  36.    # do something that causes garbage collection
  37. end 
  38.  
  39. Internally, the second co-expression get a copy of the variable c with
  40. a reference to the first co-expression even thought it doesn't use the
  41. variable c. There is no way to activate the first co-expression, but
  42. the garbage collector will save it. Dispite a few holes like this, the
  43. Icon interpreter is pretty good about only keeping things that might still
  44. be accessed by the Icon program. The Icon compiler is a little sloppier
  45. about it. It may leave things in temporary variables that are no longer
  46. needed and the garbage collector will assume that they are needed. However,
  47. in practice this doesn't seem to be a problem.
  48.  
  49.    Ken Walker, kwalker@premenos.com
  50.